<template>
  <div class="app-container" v-loading="loading">
    <el-form :inline="true" :model="queryParams">
      <div style="display: flex;flex-wrap: wrap">
        <el-col :span="4">
          <el-form-item>
            <el-input v-model="queryParams.outWeighMachine" placeholder="SKU编码" clearable/>
          </el-form-item>
        </el-col>
        <el-col :span="4">
          <el-form-item>
            <el-input v-model="queryParams.outWeighMachine" placeholder="商品名称" clearable/>
          </el-form-item>
        </el-col>

        <el-col :span="4">
          <el-form-item>
            <el-button icon="Search" type="primary" @click="getList">查询</el-button>
            <el-button icon="Refresh" @click="resetQuery">重置</el-button>
          </el-form-item>
        </el-col>
      </div>
    </el-form>
    <div>
      <el-button  type="primary"  >导出</el-button>
    </div>
    <vxe-table
        border
        style="margin-top: 10px;"
        align="center"
        :data="tableList"
        :height="tableHeight"
        :row-config="{isCurrent: true, isHover: true}"
    >
      <vxe-column type="seq" width="80" title="序号"></vxe-column>
      <vxe-column field="companyName"  width="150" title="公司名称" ></vxe-column>
      <vxe-column field="warehouseName" width="150"  title="仓库"></vxe-column>
      <vxe-column field="wayBillNum"  title="SKU编码"></vxe-column>
      <vxe-column field="outWeighTime"  title="商品名称"></vxe-column>
      <vxe-column field="outWeighMachine"  title="商品图片"></vxe-column>
      <vxe-column field="outWeighMachine"  title="代发数量"></vxe-column>
      <vxe-column field="outWeighMachine"  title="采购成本总额"></vxe-column>
      <vxe-column title="操作">
        <template #default="{row}">
          <el-button type="text"  style="color:green"  @click="clickView(row)"  >查看明细 </el-button >
        </template>
      </vxe-column>
    </vxe-table>
    <pagination
        v-show="total > 0"
        :total="total"
        v-model:page="queryParams.pageNum"
        v-model:limit="queryParams.pageSize"
        @pagination="getList"
    />

  </div>

</template>

<script setup>
import {nextTick, onMounted, reactive, ref} from "vue";
import {areaGetFilter, getOutWeighList, warehouseGetFilter} from "@/api/scApi";
import {flattenData} from "@/utils/shuangcheng";

const queryParams = ref({
  pageNum: 1,
  pageSize: 10
})
let timeData=ref([])
let total = ref(1)
let loading=ref(false)
let tableHeight = ref(0);
nextTick(() => {
  tableHeight.value = window.innerHeight - 330;
})
window.onresize = () => {
  tableHeight.value = document.body.scrollHeight - 330;
}

onMounted(()=>{

  getList()
})
let tableList = ref([ ])

function getList() {
  loading.value=true
  queryParams.value.outWeighTimeStart=timeData.value[0]
  queryParams.value.outWeighTimeEnd=timeData.value[1]
  let params={
    pageNum:queryParams.value.pageNum,
    pageSize:queryParams.value.pageSize,
    param:queryParams.value
  }
  getOutWeighList(params).then(res => {
    loading.value=false
    tableList.value =flattenData(res.data)
    total.value = res.total
  }).finally(()=>{
    loading.value = false
  })
}
const resetQuery = () => {
  timeData.value=[]
  queryParams.value = {
    pageNum: 1,
    pageSize: 10,
  }
  getList();
};

</script>

<style scoped lang="scss">
.el-form-item {
  width: 90%;
}
</style>